package org.spring.boot.func.proxy;

import org.spring.boot.func.container.FuncMethod;
import org.springframework.beans.factory.FactoryBean;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;

import java.util.List;

/**
 * @author Yiur
 */
public class FuncProxyFactory<T> implements FactoryBean<T> {

    private ConfigurableListableBeanFactory beanFactory;
    private String beanName;
    private String[] refs;
    private List<FuncMethod> beanMethods;
    private Class<T> interfaceClass;
    private Class<?> classObject;

    @Override
    @SuppressWarnings("All")
    public T getObject() throws Exception {
        return (T) new FuncProxy().funcBind(interfaceClass, classObject, beanFactory, beanName, refs, beanMethods);
    }

    @Override
    public Class<?> getObjectType() {
        return interfaceClass;
    }

    @Override
    public boolean isSingleton() {
        return true;
    }

    public Class<T> getInterfaceClass() {
        return interfaceClass;
    }

    public void setInterfaceClass(Class<T> interfaceClass) {
        this.interfaceClass = interfaceClass;
    }

    public Class<?> getClassObject() {
        return classObject;
    }

    public void setClassObject(Class<?> classObject) {
        this.classObject = classObject;
    }

    public ConfigurableListableBeanFactory getBeanFactory() {
        return beanFactory;
    }

    public void setBeanFactory(ConfigurableListableBeanFactory beanFactory) {
        this.beanFactory = beanFactory;
    }

    public String getBeanName() {
        return beanName;
    }

    public void setBeanName(String beanName) {
        this.beanName = beanName;
    }

    public List<FuncMethod> getBeanMethods() {
        return beanMethods;
    }

    public void setBeanMethods(List<FuncMethod> beanMethods) {
        this.beanMethods = beanMethods;
    }

    public String[] getRefs() {
        return refs;
    }

    public void setRefs(String[] refs) {
        this.refs = refs;
    }

}
